/* Icons.h
Copyright (c) 2008 Michael Zahniser
Please note the license terms (MIT license) at the end of this document.

Header file for the Icons class, which represents the icons used to draw the tree.
*/

#ifndef __MZ_ICONS_H__
#define __MZ_ICONS_H__

#include "_sdl/GlyphSet.h"

#include "_sdl/Surface.h"
#include "SDL.h"

#include <string>

using std::string;



class Icons : public GlyphSet {
public:
	// Constants for the different icons. These can be combined with addition.
	// For example, the [-] box is TREE_SEGMENT + EXPANDABLE + EXPANDED, plus
	// LAST_LEAF if it is the last leaf in a subtree.
	// Do not mix constants from the separate groups here.
	static const int TREE_SEGMENT = 0;
	static const int EXPANDABLE = 1;
	static const int EXPANDED = 1;
	static const int LAST_LEAF = 3;

	static const int VERTICAL_LINE = 6;

	static const int CIRCLE = 7;
	static const int CHECKED = 1;
	static const int EMPHASIZED = 2;
	
	
public:
	// Load the icons from the given path.
	void Load(const string &path);
	void Load(const string &data, int width, int height);
	
	// Draw the icon with the given index.
	void Draw(int icon, Surface &surface, const SDL_Rect &rect) const;
	
	/* Inherited from GlyphSet:
	void SetColor(unsigned char red, unsigned char green, unsigned char blue);
	int Height() const; */
	
	
private:
	void Initialize();
	
	// For convenience, keep a source rectangle here instead of recreating it for each blit.
	// Its y value, height, and width will never change after the image is loaded.
	mutable SDL_Rect source;
};



#endif

/* Copyright (c) 2008 Michael Zahniser

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. */
